﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Custom.Crm
{
    /// <summary>
    /// Gets configuration values from an XML string.
    /// </summary>
    public class Configuration
    {
        private XmlDocument m_doc = null;

        public Configuration(string config)
        {
            m_doc = new XmlDocument();
            m_doc.LoadXml(config);
        }

        /// <summary>
        /// A default for getting a value from a configuration string.
        /// </summary>
        /// <param name="key">Key Name</param>
        /// <returns>A string stored in the configuration string.</returns>
        public string this[string key]
        {
            get
            {
                try
                {
                    return m_doc.DocumentElement.SelectSingleNode(key).InnerText;
                }
                catch
                {
                    return null;
                }
            }
        }
    }
}
